package com.smartum.mpr.json.serializers;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import com.smartum.mpr.model.ItemSubCategory;

public class ItemSubCategorySerializer extends JsonSerializer<ItemSubCategory> {

	@Override
	public void serialize(ItemSubCategory value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
	        JsonProcessingException {
		jgen.writeStartObject();
		jgen.writeNumberField("subcategory_id", value.getId());
		jgen.writeStringField("subcategory_name", value.getSubCategoryName());
		jgen.writeNumberField("category_id", value.getCategory().getId());
		jgen.writeStringField("category_name", value.getCategory().getCategoryName());
		jgen.writeEndObject();

	}

}
